<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
    <link rel="stylesheet" href="./css/swiper.min.css">
    <script src="./js/swiper.min.js"></script>
    <style>
        .box{
            width: 800px;
            height: 300px;
            background-color: yellow;
            margin: auto;
        }
    </style>
</head>
<body>
    <div id="box">
        <swiper :key="dataList.length" :myconfig="{loop:true}">
            <template #slide>
                <div class="swiper-slide" v-for="item in dataList">{{item}}</div>
            </template>
            <template #arrows>
                <div class="swiper-button-next"></div>
                <div class="swiper-button-prev"></div>
            </template>
            <template #pagination>
                <div class="swiper-pagination"></div>
            </template>
        </swiper>
    </div>
    
    <script>
        Vue.component("swiper",{
            props:["myconfig"],
            template:`
                <div class="swiper-container box">
                    <div class="swiper-wrapper">
                        <slot name="slide"></slot>
                    </div>
                    <!-- Add Arrows -->
                    <slot name="arrows"></slot>
                    <!-- Add Pagination -->
                    <slot name="pagination"></slot>
                </div>
            `,
            mounted(){
                var config = {
                    loop:false,
                    navigation: {
                        nextEl: '.swiper-button-next',
                        prevEl: '.swiper-button-prev'
                    },
                    pagination: {
                        el: '.swiper-pagination',
                    },
                }
                new Swiper(".box",Object.assign(config,this.myconfig))
            }
        })
        new Vue({
            el:"#box",
            data : {
                dataList : []
            },
            created(){
                var _this = this;
                setTimeout(function(){
                    _this.dataList = ["aaa","bbb","ccc","ddd","eee","fff"];
                },2000)
            }
        })
    </script>
</body>
</html>